/**
 * <h2>字节流操作器相关.</h2>
 * <pre>
 * <b>请使用 {@link fybug.nulll.pdstream.Source.StreamSource.Bytes} 生成字节源</b>
 * 操作器均有 <b>常规操作方法</b> 用于操作 <b>稳定流</b>
 * </pre>
 *
 * @author fybug
 * @version 0.0.5
 * @since JDK 1.8
 */
package fybug.nulll.pdstream.IO.Stream;
import com.sun.istack.internal.NotNull;
import com.sun.istack.internal.Nullable;

import fybug.nulll.pdstream.Interface.UpdateSize;
/** <h2>提供缓存操作</h2> */
@SuppressWarnings( "All" )
final
class Buff {
    /** <p>更新字节缓冲区大小.</p> */
    @NotNull
    static
    byte[] upBufferSize(@Nullable final UpdateSize see, @NotNull byte[] bytesBuffer,
            final int readSize)
    {
        if (see != null) {
            int up;
            synchronized ( bytesBuffer ){
                // 更新缓冲区大小
                up = see.updataSize(readSize);
                if (up != bytesBuffer.length) {
                    if (up <= 0)
                        up = 0;
                    bytesBuffer = new byte[up];
                }
            }
        }
        return bytesBuffer;
    }
}